﻿using MediatR;
using TaskProject.Application.Command.Production;
using TaskProject.Domain.Production;
using TaskProject.ErrorCode;
using TaskProject.InfrasIntructure.Interface;

namespace TaskProject.Application.Handler.Production
{
    public class GetLeaderHandler : IRequestHandler<GetLeaderCommand, APIResult<List<LeaderModel>>>
    {
        IBaseRepository<LeaderModel> leaderRepo;

        public GetLeaderHandler(IBaseRepository<LeaderModel> leaderRepo)
        {
            this.leaderRepo = leaderRepo;
        }

        public Task<APIResult<List<LeaderModel>>> Handle(GetLeaderCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<LeaderModel>> res=new APIResult<List<LeaderModel>>();
            var leaders=leaderRepo.GetAll();
            res.Msg = "查询负责人信息成功";
            res.Code=APIEnum.Success;
            res.Data=leaders.ToList();
            return Task.FromResult(res);
        }
    }
}
